﻿<?xml version="1.0" encoding="utf-8"?>
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="5" MadCap:lastHeight="671" MadCap:lastWidth="1072">
    <head>
    </head>
    <body>
        <h1>Sample Code</h1>
        <p>MxPluginManager can be used to find a particular MxPlugin from the collection installed in the <a href="../Installation/Install-FolderFileStructure.htm">standard directory structure</a> on your PC using the code shown below. </p>
        <p class="code">&#160;</p>
        <p class="code">#include "MxProductID.h"</p>
        <p class="code">#include "MxPluginManager\MxPluginManager1.h"</p>
        <p class="code">&#160;</p>
        <p class="code">#include "PluginXml\IPluginXmlDoc.h" </p>
        <p class="code">&#160;</p>
        <p class="code">MxPluginManager pluginMngr;</p>
        <p class="code">if(pluginMngr.RefreshPluginsInRootFolder(PRODID_DefaultPluginRootFolder, SID_Universal) == true)</p>
        <p class="code">{</p>
        <blockquote>
            <p class="code"> MxPluginLib *xmlLib = pluginMngr.GetPlugin(PRODID_PluginXml);</p>
            <p class="code">if (xmlLib != nullptr) </p>
            <p class="code">{</p>
            <blockquote>
                <p class="code">IPluginXmlDoc *doc = nullptr;</p>
                <p class="code">if ((doc =  static_cast&lt;IPluginXmlDoc *&gt;(xmlLib-&gt;CreateClassInstance(IPluginXmlDocIID::Guid()))) != nullptr)</p>
                <p class="code">{</p>
                <blockquote>
                    <p class="code">...</p>
                    <p>&#160;</p>
                    <p class="code">doc-&gt;DestroyPtr();</p>
                </blockquote>
                <p class="code">}</p>
            </blockquote>
            <p class="code">}</p>
        </blockquote>
        <p class="code">}</p>
        <p class="code">&#160;</p>
        <p>Installing <a href="../Installation/Install-DownloadInstall.htm">MxPlugin</a> copies MxPluginMngr1.dll into &lt;MxRoot32&gt; and adding the <a href="../Installation/Install-DownloadInstall.htm">MxPlugin SDK</a>&#160;feature copies MxPluginMngr1.lib into &lt;MxRootSDK&gt;. Your program's Visual Studio Project then needs to add MxPluginMngr1.lib as a Linker input parameter and also add the folder containing  MxPluginManager1.h (PublicInterfaces\MxPluginManager) as one of the C++ compiler's additional include directories - see <a href="../MxPlugins/MxPlugins-UsingPlugin.htm">Using MxPlugin</a> for more details.</p>
        <ul>
            <li><b>MxProductID.h</b>&#160;defines SID_UNIVERSAL, PRODID_DefaultPluginRootFolder and PRODID_PluginXml</li>
            <li><b>PluginXml\IPluginXmlDoc.h"</b>&#160;defines IPluginXmlDoc and IPluginXmlDocIID::Guid()</li>
        </ul>
        <p class="tip">PluginXml was developed for use with different applications so SID_UNIVERSAL is passed to RefreshPluginsInRootFolder. Plugins developed for a particular application such as ImageCuratorApp would pass a more specific socket identifier like SID_ImageCurator</p>
    </body>
</html>